﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace WindowsFormsApplication1
{
    public partial class changePassword : Form
    {
        private logInModule parent;
        public changePassword(logInModule parent)
        {
            this.parent = parent;
            InitializeComponent();
        }

        private void cancel_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        private void confirm_Click(object sender, EventArgs e)
        {
            if (newPass.Text.Equals(""))
                MessageBox.Show("Password cannot be empty.", "Alert",MessageBoxButtons.OK,MessageBoxIcon.Warning);
            else if(newPass.Text.Equals(confirmPass.Text)){
                MessageBox.Show("Password successfully changed.","Success",MessageBoxButtons.OK,MessageBoxIcon.Information);
                Account account = new Account();
                account.setUserType(parent.getUserDropDown().Text);
                account.updatePassword(newPass.Text);
                this.Close();
            }
            else
                MessageBox.Show("Passwords do not match.","Alert",MessageBoxButtons.OK,MessageBoxIcon.Warning);
        }
    }
}
